package com.bwie.controller;

import com.alibaba.fastjson.JSONObject;
import com.bwie.mapper.CustomerMapper;
import com.bwie.pojo.po.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("tuBiao")
public class TuBiaoController {
    @Autowired
    private CustomerMapper customerMapper;


    @RequestMapping("tubiao")
    private String tubiao(Model model){

       List<Customer>customerList= customerMapper.list();
        ArrayList<Integer> list = new ArrayList<>();
        ArrayList<String> list1 = new ArrayList<>();

        ArrayList<Integer> list2 = new ArrayList<>();
        Integer count= customerMapper.selectCount();
        for (Customer customer : customerList) {
            list.add(customer.getCount());
            list1.add(customer.getValue());
            list2.add(count);
        }
        model.addAttribute("list", JSONObject.toJSONString(list) );
        model.addAttribute("list1",JSONObject.toJSONString(list1));
        model.addAttribute("list2",JSONObject.toJSONString(list2));
        return "tubiao";
    }

}
